<template>
    <div id="AsnDetailList">
        <v-tableTitle :btnConfig="btnConfig" :tableSelectData="selectData" @backList="backList"></v-tableTitle>
        <div class="detail">
            <v-navMenu
                    :detailNav="detailNav"
                    :menuData="menuData"
                    @setMentActive="setMentActive"
                    v-if="detailNav!=1"
            ></v-navMenu>
            <component :data="{detailData,argument}" :is="currentComponent"></component>
        </div>
    </div>

</template>

<script>
    import tableTitle from "commons/TableTitle";
    import navMenu from "commons/NavMenu";
    import baseMixin from "@/mixins/BaseMixin";

    export default {
        name: "DetailList",
        mixins: [baseMixin],
        data() {
            return {
                newFlag: false,
                argument: {},
                detailData: {},
                selectData: [],
                menuData: [
                    {label: this.$t('common.detail'), index: "2"},
                ],
                detailNav: "1",
                componentConfig: [
                    {
                        name: "Table",
                        label: "table",
                        component: () => import('./page/Table.vue')
                    },
                    {
                        name: "baisc",
                        label: this.$t('common.detail'),
                        component: () => import('./page/baisc.vue')
                    }
                ]
            }
        },
        computed: {
            btnConfig() {
                if (this.detailNav == 1) {
                    return []
                } else {
                    return [
                        {label: this.$t('common.return'), invalid: "backList"},
                    ]
                }
            },
            currentComponent() {
                return this.componentConfig[this.detailNav - 1].component;
            }
        },
        methods: {
            //选中的数据
            setSelectData(data) {
                this.selectData = data;
            },
            //进入详情
            async setdialog(data) {
                try {
                    let res = await this.$api.get(`/overcharge/detail/detailed/${this.argument.overchargekey}/${data.lineno}`);
                    
                        this.detailData = res.bean;
                        this.detailNav = "2";
                    
                } catch (e) {
                    this.$message.error(e);
                }
            },
            //返回试图
            backList() {
                this.detailNav = "1";
            },
            //导航值
            setMentActive(key) {
                this.detailNav = key;
            },

        },
        mounted() {
            this.newFlag = this.$store.state.newFlag;
            if (Object.keys(this.$store.state.skip).length !== 0) {
                let data = this.$store.state.skip;
                this.argument = data.routeData;
                this.detailData = data.detailList;
                this.detailNav = data.detailListNav;
            } else {
                this.argument = this.$store.state.routeData;
            }

        },
        components: {
            "v-tableTitle": tableTitle,
            "v-navMenu": navMenu,
        },
        watch: {}
    }
</script>

<style>

</style>
